package com.hedl.practice.studyRandom;

import java.security.SecureRandom;
import java.util.Arrays;

//安全随机数
public class SecureRandoms {
    public static void main(String[] args) {
        SecureRandom sr = null;

        //System.out.println(new SecureRandom().nextInt(100));

        try{
            sr = SecureRandom.getInstanceStrong();      //获取高强度的安全随机生成器
        }catch(Exception e){
            e.printStackTrace();
            sr = new SecureRandom();        //获取普通的安全随机生成器
        }
        byte[] buffer = new byte[6];
        sr.nextBytes(buffer);       //用安全随机数填充buffer
        System.out.println(Arrays.toString(buffer));
    }
}
